// pages/banghui/inviter.js
const app = getApp()
var http = require('../../utils/server.js');
var util = require('../../utils/util.js');
Page({
  data: {
  },

  onLoad: function() {
    var that = this
    var currentUserInfo = wx.getStorageSync('userInfo');
    console.log(currentUserInfo)
    if (currentUserInfo) {
      that.setData({
        userId: currentUserInfo.userId,
        avatar: currentUserInfo.avatar,
        userName: currentUserInfo.name,
        gangName: currentUserInfo.gangName,
        inviterId: currentUserInfo.userId,
        gangId: currentUserInfo.gangId,
      })
      http.post({
        url: "gang/getinfo",
        gang_id: that.data.gangId
      }, function(data) {
        that.setData({
          gangAvatar: data.avatar,
          gangName: data.name,
          userName: data.wx_nickname ? data.wx_nickname:currentUserInfo.name,
        })
      })

    }
  },
  onShareAppMessage: function() {
    console.log('/pages/banghui/join?scene=' + this.data.inviterId)
    return {
      title: '邀请您加入【' + this.data.gangName + '】帮会',
      path: '/pages/banghui/join?scene=' + this.data.inviterId,
      imageUrl: 'https://www.ymqvip.com/static/images/inviter.png'
    }
  },
  openImg: function (e) { 
    wx.previewImage({
      urls: ['https://sys.ymqvip.com/index/getJoinGangQrcode?user_id=' + this.data.userId]
    })
  },
  formSubmit: function(e) {
    // http.post({
    //   url: "gang/getinfo",
    //   gang_id: that.data.gangId
    // }, function (data) {
    //   that.setData({
    //     gangAvatar: data.avatar
    //   })
    // })
  }
})